<?php include '../../entries/noauth.php';
/**
 *  录入电表信息
 *
 */
class Surface extends Restful{


    public function valid() {
        return [
            'post|mobile|exist|mobile必须传递！',
            'post|password|exist|password必须传递！',
        ];
    }

    public function action(){
        $mobile = post('mobile');
        $password = post('password');
        $info = Mdb::query(MDB_MAIN,'select * from adm_prop_worker where mobile = ? and password = ?',[$mobile, base64_encode($password)]);
        if(empty($info)){
            return Res::eIllegal('用户名或密码错误！');
        }
        $cmtInfo = Mdb::query(MDB_MAIN,'select name from prop_community where id = ?',[$info[0]['cmt_id']]);
        $info[0]['cmt_name'] = $cmtInfo[0]['name'];
        $this->session->setItem('user',json_encode($info[0]));
        return Res::ok();
    }
}

new Surface();